package com.example.springbootjpa.service.impl;

import com.example.springbootjpa.model.Teacher;
import com.example.springbootjpa.reposity.TeacherReposity;
import com.example.springbootjpa.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherReposity reposity;

    @Override
    public List<Teacher> selectAll() {
        return reposity.findAll();
    }

    @Override
    public void add(Teacher teacher) {
        reposity.save(teacher);
    }

    @Override
    public void update(Teacher teacher) {
        reposity.saveAndFlush(teacher);
    }

    @Override
    public void delete(int id) {
        reposity.deleteById(id);
    }
}
